package org.progin.cloudfolder.msg;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Msg {
	private byte _id;
	
	public Msg() {}

	public void initRead(DataInputStream is) throws IOException {
		_id = is.readByte();
	}

	public void write(Payload payload, DataOutputStream os) throws IOException {
		os.writeByte(payload.getId());
		payload.write(os);
	}

	public void write(byte payloadId, DataOutputStream os) throws IOException {
		os.writeByte(payloadId);
	}
	
	public void read(Payload payload, DataInputStream is) throws IOException {
		payload.read(is);
	}
	
	public boolean isPayloadTypeEquals(byte payloadType) {
		return _id == payloadType;
	}

	public byte getID(){
		return _id;
	}
}
